package mlz.d_datastream;

import org.junit.Test;

import java.io.*;
import java.sql.SQLOutput;

/*
    数据流
 */
public class DaraStreamDemo01 {
    @Test
    public void test01() throws IOException {
        DataOutputStream dos = new DataOutputStream(
                new FileOutputStream("data.txt"));

        dos.writeInt(97);
        dos.writeDouble(3.14);
        dos.writeUTF("你好世界!!666");

    }

    @Test
    public void test02() throws IOException {
        DataInputStream dis = new DataInputStream(
                new FileInputStream("data.txt"));

        //读取数据
        int i = dis.readInt();
        System.out.println(i);
        double d = dis.readDouble();
        System.out.println(d);
        String s = dis.readUTF();
        System.out.println(s);
    }
}












